package com.imnc.foodmap.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.baidu.mapapi.map.LocationData;

public class LocationDataParcelable extends LocationData implements Parcelable {

	public LocationDataParcelable() {
	}

	public LocationDataParcelable(LocationData locationData) {
		this.accuracy = locationData.accuracy;
		this.direction = locationData.direction;
		this.latitude = locationData.latitude;
		this.longitude = locationData.longitude;
		this.satellitesNum = locationData.satellitesNum;
		this.speed = locationData.speed;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeFloat(this.accuracy);
		dest.writeFloat(this.direction);
		dest.writeDouble(this.latitude);
		dest.writeDouble(this.longitude);
		dest.writeInt(this.satellitesNum);
		dest.writeFloat(this.speed);
	}

	public final static Parcelable.Creator<LocationDataParcelable> CREATOR = new Creator<LocationDataParcelable>() {

		@Override
		public LocationDataParcelable createFromParcel(Parcel source) {
			LocationDataParcelable locationData = new LocationDataParcelable();
			locationData.accuracy = source.readFloat();
			locationData.direction = source.readFloat();
			locationData.latitude = source.readDouble();
			locationData.longitude = source.readDouble();
			locationData.satellitesNum = source.readInt();
			locationData.speed = source.readFloat();

			return locationData;
		}

		@Override
		public LocationDataParcelable[] newArray(int size) {
			return new LocationDataParcelable[size];
		}
	};
}
